#include<iostream>
#include<cmath>
using namespace std;

int main() {
	int n;
	cin >> n;
	int e = 1;
	int s = 1;
	for (int i = 0; i < n; i++) {
		if (i < n - 1) {
			s *= 10;
		}
		e *= 10;
	}
	for (int i = s; i < e; i++) {
		int sum = 0;
		int temp = i;
		int num;
		for (int j = 1; j <= n; j++) {
			num = temp % 10;
			sum += pow(num, n);
			temp /= 10;
		}
		if (sum == i)cout << i << " ";
	}
}